<template>
	<view class="page-body">
		<el-form :inline="true" class="demo-form-inline">
		  <el-form-item label="小区名称">
		    <el-select v-model="value" filterable placeholder="请选择">
		        <el-option
		          v-for="item in options"
		          :key="item._id"
		          :label="item.name"
		          :value="item._id">
		        </el-option>
		      </el-select>
		  </el-form-item>
      <el-form-item>
        <el-input v-model="min" placeholder="请输入房源最小值"></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="max" placeholder="请输入房源最大值"></el-input>
      </el-form-item>
		  <el-form-item>
		    <el-button type="primary" @click="onSubmit">查询</el-button>
		  </el-form-item>
		</el-form>
    <el-table
        :data="tableData"
        style="width: 100%"
        max-height="500">
        <el-table-column
          fixed
          prop="address_str"
          label="小区名称"
          width="200">
        </el-table-column>
        <el-table-column
          prop="address_map"
          label="小区地址"
          width="240">
        </el-table-column>
        <el-table-column
          prop="subway_str"
          label="地铁线路"
          >
        </el-table-column>
        <el-table-column
          prop="house_all_str"
          label="房源户型"
          >
        </el-table-column>
        <el-table-column
          prop="area"
          label="房源面积"
          >
        </el-table-column>
        <el-table-column
          prop="salary"
          label="房源租金"
          >
        </el-table-column>
        <el-table-column
          prop="lease_str"
          label="租赁方式"
          >
        </el-table-column>
        <el-table-column
          label="房源展示"
          width="300">
          <template slot-scope="scope">
            <view style="display:flex">
              <el-link type="primary" @tap="showImg(scope.$index, tableData)">查看图片</el-link>
              <el-link style="margin-left: 20px;cursor:pointer" type="primary" @tap="showVideo(scope.$index, tableData)">查看视屏</el-link>
            </view>  
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          label="操作"
          width="180">
          <template slot-scope="scope">
            <el-button
              @click.native.prevent="auditRow(scope.$index, tableData)"
              type="text"
              size="small">
              详情
            </el-button>
            <el-button
            v-if="tableData[scope.$index].status==2"
              @click.native.prevent="auditRow(scope.$index, tableData)"
              type="text"
              size="small">
              审核上架
            </el-button>
            <el-button
            v-if="tableData[scope.$index].status==3"
              @click.native.prevent="onRow(scope.$index, tableData)"
              type="text"
              size="small">
              上架
            </el-button>
            <el-button
              v-if="tableData[scope.$index].status==1"
              @click.native.prevent="offRow(scope.$index, tableData)"
              type="text"
              size="small">
              下架
            </el-button>
            <el-button
              v-if="tableData[scope.$index].status==3"
              @click.native.prevent="deleteRow(scope.$index, tableData)"
              type="text"
              size="small">
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>

		<!-- 页面内容结束 -->
	</view>
</template>
<script>
  export default {
    data() {
      return {
        min: '',
        max: '',
        value: '',
        lease_arr: [
          {
            value: 1,
            text: '整租'
          },
          {
            value: 2,
            text: '合租'
          }
        ],
        tableData: []
      }
    },
    watch: {
      list:{
        handler(nv) {
          this.tableData = nv
        },
        immediate: true,
        deep: true
      }
    },
    props: {
      options: {
        type: Array,
        default: function() {
          return []
        }
      },
      list: {
        type: Array,
        default: function() {
          return []
        }
      },
    },
    onShow() {
      this.getXiaoqu()
    },
    methods: {
      onSubmit() {},
      auditRow(index) {},
      onRow(index) {},
      offRow(index) {},
      deleteRow(index) {
        let that = this
        uni.showModal({
					content: '确定要删除该房源吗？',
					success(res) {
            that.trueDelete(index)
					}
				})
      },
      async trueDelete(index) {
        let info2 = await this.vk.callFunction({
          url: 'user/kh/houseDelete',
          title: '请求中...',
          isRequest: true,
          data: {
            _id: this.list[index]._id
          }
        });
        if (info2.code == 0) {
          this.$emit('change')
        }
      }
    }
  }
</script>
<style lang="scss" scoped>

</style>
